<%--
  Created by IntelliJ IDEA.
  User: 惠普
  Date: 2021/8/16
  Time: 上午11:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
</head>
<body>
<center>
    <input type="text" name="username" id="username">账号
    <input type="password" name="password" id="password">密码
    <button onclick="login()">登录</button>
</center>
</body>
<script src="jquery-1.8.3.min.js"></script>
<script>
    function login() {
        var username = $.trim(document.getElementById("username").value);
        var password = $.trim(document.getElementById("password").value);
        if (username == "" || password == "") {
            alert("账号或密码不能为空！");
            return;
        } else {
            alert("1")
            $.ajax({
                url: "/login",
                type: "POST",
                data: {"username":username,"password":password},
                dataType: "JSON",
                success: function (data) {
                    alert(data)
                    if(data.logingg == "ok")
                    {
                        alert("登录成功！")
                    }
                else
                    {
                        alert("登录失败")
                    }
                }
            })
        }
    }
</script>
</html>
